

#include "../../Common/pcap_engine/pcap_engine.h"

class network_filter_test_ethernet
	:public network_filter_base
{
public:
	network_filter_test_ethernet()
		:network_filter_base(FAD_ETHERNET, FAD_ETHERNET)
	{
		;
	}

	virtual ~network_filter_test_ethernet(){}

	virtual void process_network_data(FILTER_ACCEPT_DATATYPE type, void * ptr_data)
	{
		if (type == FAD_ETHERNET)
		{
			network_ethernet_data * ptr_ethernet_data = (network_ethernet_data *)ptr_data;

			char timestr[16];

#ifdef _WIN32
			tm time_s;
			tm * ptr_time = &time_s;
			localtime_s(ptr_time, &(ptr_ethernet_data->time));
#else
			tm * ptr_time = localtime(&(ptr_ethernet_data->time));
#endif

			strftime(timestr, sizeof timestr, "%H:%M:%S", ptr_time);

			printf("%s\tSrc: %02x:%02x:%02x:%02x:%02x:%02x   Dst: %02x:%02x:%02x:%02x:%02x:%02x   Size: %d\tType: %04x\n",
				timestr,
				ptr_ethernet_data->ether_shost[0],
				ptr_ethernet_data->ether_shost[1],
				ptr_ethernet_data->ether_shost[2],
				ptr_ethernet_data->ether_shost[3],
				ptr_ethernet_data->ether_shost[4],
				ptr_ethernet_data->ether_shost[5],
				ptr_ethernet_data->ether_dhost[0],
				ptr_ethernet_data->ether_dhost[1],
				ptr_ethernet_data->ether_dhost[2],
				ptr_ethernet_data->ether_dhost[3],
				ptr_ethernet_data->ether_dhost[4],
				ptr_ethernet_data->ether_dhost[5],
				ptr_ethernet_data->ptr_data->get_datasize_by_tag( NDT_ETHERNET_DATA ),
				ntohs(ptr_ethernet_data->ether_type));

			send_network_data(type, ptr_data);
		}
		else
		{
			std::cout << "Error!!!!!!We should not recv this kind of data!!!!!" << std::endl;
		}
	}
};
